package com.ruoyi.recipe.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.recipe.mapper.RecipeArticleFavoriteMapper;
import com.ruoyi.recipe.domain.RecipeArticleFavorite;
import com.ruoyi.recipe.service.IRecipeArticleFavoriteService;
import com.ruoyi.common.core.text.Convert;

/**
 * 文章收藏Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-02-14
 */
@Service
public class RecipeArticleFavoriteServiceImpl implements IRecipeArticleFavoriteService 
{
    @Autowired
    private RecipeArticleFavoriteMapper recipeArticleFavoriteMapper;

    /**
     * 查询文章收藏
     * 
     * @param userId 文章收藏主键
     * @return 文章收藏
     */
    @Override
    public RecipeArticleFavorite selectRecipeArticleFavoriteByUserId(Long userId)
    {
        return recipeArticleFavoriteMapper.selectRecipeArticleFavoriteByUserId(userId);
    }

    /**
     * 查询文章收藏列表
     * 
     * @param recipeArticleFavorite 文章收藏
     * @return 文章收藏
     */
    @Override
    public List<RecipeArticleFavorite> selectRecipeArticleFavoriteList(RecipeArticleFavorite recipeArticleFavorite)
    {
        return recipeArticleFavoriteMapper.selectRecipeArticleFavoriteList(recipeArticleFavorite);
    }

    /**
     * 新增文章收藏
     * 
     * @param recipeArticleFavorite 文章收藏
     * @return 结果
     */
    @Override
    public int insertRecipeArticleFavorite(RecipeArticleFavorite recipeArticleFavorite)
    {
        recipeArticleFavorite.setCreateTime(DateUtils.getNowDate());
        return recipeArticleFavoriteMapper.insertRecipeArticleFavorite(recipeArticleFavorite);
    }

    /**
     * 批量删除文章收藏
     * 
     * @param userIds 需要删除的文章收藏主键
     * @return 结果
     */
    @Override
    public int deleteRecipeArticleFavoriteByUserIds(String userIds)
    {
        return recipeArticleFavoriteMapper.deleteRecipeArticleFavoriteByUserIds(Convert.toStrArray(userIds));
    }

    /**
     * 删除文章收藏信息
     * 
     * @param userId 文章收藏主键
     * @return 结果
     */
    @Override
    public int deleteRecipeArticleFavoriteByUserId(Long userId)
    {
        return recipeArticleFavoriteMapper.deleteRecipeArticleFavoriteByUserId(userId);
    }

    @Override
    public int deleteRecipeArticleFavoriteByOpenId(String openId) {
        return recipeArticleFavoriteMapper.deleteRecipeArticleFavoriteByOpenId(openId);
    }

    @Override
    public int deleteRecipeArticleFavoriteByOpenIds(String openIds) {
        return recipeArticleFavoriteMapper.deleteRecipeArticleFavoriteByOpenIds(openIds);
    }

    @Override
    public int deleteRecipeArticleFavoriteByArticleId(Long articleId) {
        return recipeArticleFavoriteMapper.deleteRecipeArticleFavoriteByArticleId(articleId);
    }

    @Override
    public int deleteRecipeArticleFavoriteByArticleIds(String[] articleIds) {
        return recipeArticleFavoriteMapper.deleteRecipeArticleFavoriteByArticleIds(articleIds);
    }

    @Override
    public int deleteRecipeArticleFavorite(RecipeArticleFavorite recipeArticleFavorite) {
        return recipeArticleFavoriteMapper.deleteRecipeArticleFavorite(recipeArticleFavorite);
    }
}
